/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package view;

import controller.Controller;
import javax.swing.JInternalFrame;
import javax.swing.JTextField;

/**
 *
 * @author Arnaud
 */
public class View extends javax.swing.JFrame {

    private Controller controller;
    /**
     * Creates new form View
     */
    public View(Controller c) {
        controller = c;
        initComponents();
        this.setVisible(true);
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        buttonGroupSpecialite = new javax.swing.ButtonGroup();
        jTabbedPane1 = new javax.swing.JTabbedPane();
        jPanel1 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        textPaneAnswer = new javax.swing.JTextPane();
        buttonLaunch = new javax.swing.JButton();
        comboBoxAlgo = new javax.swing.JComboBox();
        radioButtonEcole = new javax.swing.JRadioButton();
        radioButtonSpecialite = new javax.swing.JRadioButton();
        textFieldUser = new javax.swing.JTextField();
        jLabel1 = new javax.swing.JLabel();
        jScrollPane2 = new javax.swing.JScrollPane();
        textPaneUser = new javax.swing.JTextPane();
        InternalFrameGraph = new javax.swing.JInternalFrame();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jScrollPane1.setViewportView(textPaneAnswer);

        buttonLaunch.setText("Launch");
        buttonLaunch.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonLaunchActionPerformed(evt);
            }
        });

        comboBoxAlgo.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "BASIC", "AGG", "CLIQUE" }));
        comboBoxAlgo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                comboBoxAlgoActionPerformed(evt);
            }
        });

        buttonGroupSpecialite.add(radioButtonEcole);
        radioButtonEcole.setText("Ecole");
        radioButtonEcole.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                radioButtonEcoleActionPerformed(evt);
            }
        });

        buttonGroupSpecialite.add(radioButtonSpecialite);
        radioButtonSpecialite.setText("Specialite");
        radioButtonSpecialite.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                radioButtonSpecialiteActionPerformed(evt);
            }
        });

        textFieldUser.setText("100003256678055");
        textFieldUser.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                textFieldUserKeyReleased(evt);
            }
        });

        jLabel1.setText("id_utilisateur");

        jScrollPane2.setViewportView(textPaneUser);

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(25, 25, 25)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(comboBoxAlgo, javax.swing.GroupLayout.PREFERRED_SIZE, 76, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(buttonLaunch, javax.swing.GroupLayout.PREFERRED_SIZE, 76, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(radioButtonEcole)
                    .addComponent(radioButtonSpecialite)
                    .addComponent(jLabel1)
                    .addComponent(textFieldUser, javax.swing.GroupLayout.PREFERRED_SIZE, 106, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(36, 36, 36)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 498, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 213, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(71, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(41, 41, 41)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                        .addComponent(radioButtonEcole)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(radioButtonSpecialite)
                        .addGap(41, 41, 41)
                        .addComponent(comboBoxAlgo, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(buttonLaunch, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 186, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(49, 49, 49)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jLabel1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(textFieldUser, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 190, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(22, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab("tab1", jPanel1);

        InternalFrameGraph.setResizable(true);
        InternalFrameGraph.setVisible(true);

        javax.swing.GroupLayout InternalFrameGraphLayout = new javax.swing.GroupLayout(InternalFrameGraph.getContentPane());
        InternalFrameGraph.getContentPane().setLayout(InternalFrameGraphLayout);
        InternalFrameGraphLayout.setHorizontalGroup(
            InternalFrameGraphLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 720, Short.MAX_VALUE)
        );
        InternalFrameGraphLayout.setVerticalGroup(
            InternalFrameGraphLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 459, Short.MAX_VALUE)
        );

        jTabbedPane1.addTab("tab2", InternalFrameGraph);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 741, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(0, 0, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 516, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(0, 0, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void comboBoxAlgoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_comboBoxAlgoActionPerformed
        controller.controllerChooseAlgo(comboBoxAlgo.getSelectedIndex());
    }//GEN-LAST:event_comboBoxAlgoActionPerformed

    private void buttonLaunchActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonLaunchActionPerformed
        controller.controllerLaunchAlgo();
    }//GEN-LAST:event_buttonLaunchActionPerformed

    private void radioButtonEcoleActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_radioButtonEcoleActionPerformed
        controller.controllerChooseOption(false);
    }//GEN-LAST:event_radioButtonEcoleActionPerformed

    private void radioButtonSpecialiteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_radioButtonSpecialiteActionPerformed
        controller.controllerChooseOption(true);
    }//GEN-LAST:event_radioButtonSpecialiteActionPerformed

    private void textFieldUserKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_textFieldUserKeyReleased
        controller.controllerChooseUser(textFieldUser.getText());
    }//GEN-LAST:event_textFieldUserKeyReleased

    public void displayAlgoAnswer(String a)
    {
        textPaneAnswer.setText(a);
    }
    
    public void displayUserProfil(String p)
    {
        textPaneUser.setText(p);
    }

    public JInternalFrame getInternalFrameGraph() {
        return InternalFrameGraph;
    }

    public JTextField getTextFieldUser() {
        return textFieldUser;
    }

    
    
    
    /**
     * @param args the command line arguments
     */
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JInternalFrame InternalFrameGraph;
    private javax.swing.ButtonGroup buttonGroupSpecialite;
    private javax.swing.JButton buttonLaunch;
    private javax.swing.JComboBox comboBoxAlgo;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JRadioButton radioButtonEcole;
    private javax.swing.JRadioButton radioButtonSpecialite;
    private javax.swing.JTextField textFieldUser;
    private javax.swing.JTextPane textPaneAnswer;
    private javax.swing.JTextPane textPaneUser;
    // End of variables declaration//GEN-END:variables
}
